<script>
	import { getCode, login ,uploadImages,userIsLogin,getUserTemplateConf} from './utils/api.js';
export default {
	
	onLaunch: function() {
		console.log('App Launch');
		let extConfig = uni.getExtConfigSync() ? uni.getExtConfigSync() : {};
		console.log(extConfig,88888);
			// let params = {
			// 	userServiceToken: this.userToken
			// }
			// getUserTemplateConf(params).then(res => {
			// 	if (res.code == 200&&res.body) {
			// 		let templateConfig=JSON.parse(res.body.templateConf.templateConfJson);
			// 		uni.setStorage({
			// 			key: '__template',
			// 			data: templateConfig
			// 		});
			// 	}
			// })
	},

	onShow: function() {
		userIsLogin().then(sult=>{
			if(sult.code==200&&!sult.body.isLogin){
				let identification = '';
					uni.login({
						provider: 'weixin',
						success: function(wxs) {
							getCode({
								code: wxs.code
							}).then(res => {
								identification = res.body.openid;
								uni.setStorage({
									key: '__ddminiUserOpenid',
									data: identification
								});
								let user = {
									identification: identification,
								};
								let postData = `wechatServerJSON=${JSON.stringify(user)}`;
								login(postData).then(wes => {
									if (wes.code == 200) {
										uni.hideLoading();
										uni.setStorage({
											key: 'userInfo',
											data: wes.body
										});
									} else {
										uni.hideLoading();
										uni.showModal({
											title: '授权失败',
											content: wes.msg,
											showCancel: false
										});
									}
								});
								
							});
						}
					});
			}else{
				
			}
		})
		
		
	},
	onHide: function() {
		console.log('App Hide');
	}
};
</script>

<style lang="scss">
/*每个页面公共css */
page {
	box-sizing: border-box;
}
</style>
